/**
 * PHOSIDE: PHosphorylation Site IDentification Engine.
 * Copyright 2009 Digital Biology Lab, University of Missouri.
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 3 of the License, or (at your option) any later
 * version. <p/> This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License for more
 * details.
 */

package phoside.util;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author gjj
 */
public class ListUtil {
    public static void fillList(List l, Object obj, int n) {
        for (int i=0; i<n; i++) {
            l.add(obj);
        }
    }

    public static List subList(List l, int begin, int end) {
        if (l==null) {
            throw new java.lang.NullPointerException();
        }

        if (begin<0 || begin>=end || end>l.size()) {
            throw new java.lang.IndexOutOfBoundsException();
        }

        List ret = new ArrayList();
        for (int i=begin; i<end; i++) {
            ret.add(l.get(i));
        }

        return ret;
    }
}
